package service;

import com.pugwoo.wooutils.redis.anatation.SOALockService;
import org.springframework.stereotype.Service;

@Service
public class MyService {


    @SOALockService(nameSpace = "namespace1",expire = 10)
    public void service1(){
        System.out.println("Hello world");
    }


    @SOALockService(nameSpace = "namespace1",expire = 10,waitSOALockTime = 3)
    public void service2() {
        System.out.println("开始执行任务,此任务耗时5秒钟....");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("["+Thread.currentThread().getName()+"]耗时任务已执行完成,输出:Hello world");
    }


    @SOALockService(nameSpace = "namespace3",expire = 2)
    public void service3() {
        System.out.println("开始执行任务,此任务耗时3秒钟....");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("["+Thread.currentThread().getName()+"]耗时任务已执行完成,输出:Hello world");
    }

    @SOALockService(nameSpace = "namespace4",expire = 2)
    public void service4() {
        System.out.println("开始执行任务,此任务耗时3秒钟....");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("["+Thread.currentThread().getName()+"]耗时任务已执行完成,输出:Hello world");
    }

    @SOALockService(nameSpace = "namespace5",expire = 2,waitSOALockTime = 10)
    public void service5() {
        System.out.println("开始执行任务,此任务耗时4秒钟....");
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("["+Thread.currentThread().getName()+"]耗时任务已执行完成,输出:Hello world");
    }

}
